package com.sunxiansheng.designPattern.factoryandstragy;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * Description: 测试的controller
 * @Author sun
 * @Create 2024/7/22 12:15
 * @Version 1.0
 */
@Controller
public class PayTestController {

    @Resource
    private ServiceHandler serviceHandler;

    @RequestMapping("/payTest/{payType}")
    public void test(@PathVariable("payType") String payType) {
        // 根据类型来判断使用哪个策略
        if (Objects.equals(payType, "支付宝")) {
            serviceHandler.dealPay(PayChannelEnum.ZFB_PAY.getCode());
        } else if (Objects.equals(payType, "微信")) {
            serviceHandler.dealPay(PayChannelEnum.WX_PAY.getCode());
        } else if (Objects.equals(payType, "银行")) {
            serviceHandler.dealPay(PayChannelEnum.BANK_PAY.getCode());
        }
    }

}